#include "core/image2d.h"
#include "core/lastError.h"
#include "../image2d_ptr.h"

namespace Image2D {



Image2D_Ptr::Image2D_Ptr()
{
    m_image2d = std::make_shared<Image2D_Imp>();
}

Image2D_Ptr::Image2D_Ptr(const Image2D_Ptr& i2d)
{
    m_image2d = std::make_shared<Image2D_Imp>(i2d.data(), i2d.linesize(), i2d.width(), i2d.height(), i2d.format(), i2d.type());
}

Image2D_Ptr::Image2D_Ptr(int width, int height, ImageFormat format, ImageType type)
{
    m_image2d = std::make_shared<Image2D_Imp>(width, height, format, type);
}

Image2D_Ptr::Image2D_Ptr(const void** data, const size_t* linesize, int width, int height, ImageFormat format, ImageType type)
{
    m_image2d = std::make_shared<Image2D_Imp>(data, linesize, width, height, format, type);
}

Image2D_Ptr::~Image2D_Ptr()
{

}

int Image2D_Ptr::width() const
{
    return m_image2d->width();
}
int Image2D_Ptr::height() const
{
    return m_image2d->height();
}

const void**  Image2D_Ptr::data() const
{
    return m_image2d->data();
}

const void* Image2D_Ptr::data(int index) const
{
    return m_image2d->data(index);
}

const size_t* Image2D_Ptr::linesize() const
{
    return m_image2d->linesize();
}

size_t Image2D_Ptr::linesize(int index) const
{
    return m_image2d->linesize(index);
}

ImageFormat Image2D_Ptr::format() const
{
    return m_image2d->format();
}

ImageType   Image2D_Ptr::type() const
{
    return m_image2d->type();
}

int Image2D_Ptr::typeSize()          const
{
    return m_image2d->typeSize();
}

int   Image2D_Ptr::lastErrorCode()
{
    return LastError::getLastErrorCode();
}

std::string   Image2D_Ptr::lastErrorStr()
{
    return LastError::getLastErrorStr();
}


int lastErrorCode()
{
    return LastError::getLastErrorCode();
}

std::string lastErrorStr()
{
    return LastError::getLastErrorStr();
}

}